from __future__ import annotations

from dataclasses import dataclass


@dataclass
class UpliftDetail:
    effective_stress_kPa: float
    hydraulic_head_m: float
    safety_factor: float
    note: str


def check_uplift_detailed(water_level_out_m: float, water_level_in_m: float, excavation_depth_m: float, soil_unit_weight_kN_m3: float = 18.0, water_unit_weight_kN_m3: float = 9.81) -> UpliftDetail:
    """抗底隆起细化：计算基底有效应力与水头差，Fs=σ'/(γ_w·Δh)。"""

    delta_h = max(0.0, water_level_out_m - water_level_in_m)
    sigma_eff = (soil_unit_weight_kN_m3 - water_unit_weight_kN_m3) * excavation_depth_m
    demand = water_unit_weight_kN_m3 * delta_h
    Fs = sigma_eff / max(1e-6, demand)
    return UpliftDetail(effective_stress_kPa=sigma_eff * 1000.0, hydraulic_head_m=delta_h, safety_factor=Fs, note="Fs≥1.25")


